package com.medical.admin.sys.common.validate.validation;

import com.medical.admin.sys.common.validate.IsPhone;
import org.springframework.util.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/*
 * @Date : 2024/4/28 上午9:23
 * @Created by Lang
 * @ProjectName : medical-appointment-registration
 */
public class IsPhoneValidation implements ConstraintValidator<IsPhone, String> {
    @Override
    public void initialize(IsPhone constraintAnnotation) {
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isEmpty(value)) {
            return false;
        } else {
            return IphoneValidationUtil.isPhone(value);
        }
    }
}
